/**
 * Created by PC on 2016/3/11.
 */
(function($){
    $.extend({
        admin:{
            delConfirm:function(data){
                var _this          = this,
                    datas          = {},
                    options        = null,
                    $confirm       = $('.tip'),
                    $confirmAccept = $('.sure'),
                    $confirmCancel = $('.cancel'),
                    $info          = $('.tipinfo'),
                    $close         = $('.tiptop').find('a');
                datas.txt          = '是否确认对信息的修改 ？';                                                                                //默认说明文本
                datas.txtTip       = '如果是请点击确定按钮 ，否则请点取消。';
                datas.acceptBtn    = '确认';                                                                              //默认确认按钮
                datas.cancelBtn    = '取消';                                                                              //默认取消按钮
                datas.accept       = function(){};
                datas.cancel       = function(){};
                options            = $.extend(datas,data);

                $confirm.fadeIn();
                $info.find('p').html(options.txt);
                $info.find('cite').html();

                $confirmAccept.html(options.acceptBtn).one('click',function(){
                    $confirmCancel.off('click');
                    $(this).parents('.tip').fadeOut(100,function(){
                        options.accept();
                    });
                });
                $confirmCancel.html(options.cancelBtn).one('click',function(){
                    $confirmAccept.off('click');
                    $(this).parents('.tip').fadeOut(100,function(){
                        options.cancel();
                    });
                });
                $close.one('click',function(){
                    $(this).parents('.tip').fadeOut(200);
                    $confirmAccept.off('click');
                    $confirmCancel.off('click');
                })
            }
        },
        range:function(selector){                                                                                   //居中绝对定位方法
            var clientWidth  = $(window).width(),
                clientHeight = $(window).height(),
                boxWidth,
                boxHeight,
                rang         = {},
                $selector    = $(selector);
            boxHeight        = $selector.height();
            boxWidth         = $selector.width();
            rang.top         = clientHeight/2-boxHeight/2-parseInt($selector.css('padding-top'));
            rang.left        = clientWidth/2-boxWidth/2-parseInt($selector.css('padding-left'));
            return rang;
        }
    })
})($);
